<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Expires" content="Fri, Jan 01 1900 00:00:00 GMT">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Lang" content="en">
<meta name="author" content="">
<meta http-equiv="Reply-to" content="@.com">
<meta name="generator" content="PhpED 6.0">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="creation-date" content="06/01/2011">
<meta name="revisit-after" content="15 days">
<title>Untitled</title>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.8.18/themes/base/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.8.18/themes/ui-lightness/jquery-ui.css">

<style type="text/css">
    .clear{
        clear: both;
    }
        .container{
            /*background-color: yellow;
            width: 1240px;*/
        }
        .colbox{
            float: left;
            width: 400px;
            margin-right: 2px;
            border: 1px solid silver;
        }
        .colboxtop{
            text-align: center;
        }
        .column { width: 196px; float: left; padding-bottom: 100px;
            /*background-color: #D5FFE7;*/
            margin: 2px;
        }
        .portlet { margin-bottom: 2px; }
        .portlet-header { margin: 0.3em; padding-bottom: 4px; padding-left: 0.2em; }
        .portlet-header .ui-icon { float: right; }
        .portlet-content { padding: 0.4em; /*display: none;*/ }
        .ui-sortable-placeholder { border: 1px dotted black; visibility: visible !important; height: 50px !important; }
        .ui-sortable-placeholder * { visibility: hidden; }
        
        .todo .portlet-header{
            background-color: #FCC74B;
        }
        .inprocess .portlet-header{
            background-color: #D5FFE7;
        }
        .done .portlet-header{
            background-color: #B6FF48;
        }
</style>

<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>
<script src="https://raw.github.com/furf/jquery-ui-touch-punch/master/jquery.ui.touch-punch.min.js"></script>

<script>
$(function() {
  $( ".column" ).sortable({
    connectWith: ".column",
    start: function(event, ui) {
        //var id = $(this).attr('id');
        //alert(id);
        //alert(event.attr('id'));
    },
    beforeStop: function(event, ui) {
        var $curentElement = ui.item;//the div dang dc thuc thi
        var colindex = $curentElement.attr("colindex");
        var newColindex = $curentElement.parent().attr("colindex");
        
        if(colindex == "todo"){
            if(newColindex == "done"){
                $(this).sortable('cancel');
            }
        }else if(colindex == "inprocess"){
            /*if(newColindex == "todo"){
                $(this).sortable('cancel');
            }*/
        }else if(colindex == "done"){
            if(newColindex == "todo" || newColindex == "inprocess"){
                $(this).sortable('cancel');
            }
        }else{
            $(this).sortable('cancel');
        }
    },
    stop: function(event, ui) { 
        var $curentElement = ui.item;//the div dang dc thuc thi
        var colindex = $curentElement.attr("colindex");
        var newColindex = $curentElement.parent().attr("colindex");
        
        $curentElement.removeClass(colindex);
        $curentElement.addClass(newColindex);
        $curentElement.attr("colindex",newColindex);
    }
  });

  $( ".portlet" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
    .find( ".portlet-header" )
      //.addClass( "ui-widget-header ui-corner-all" )
      .addClass( "ui-corner-all" )
      .prepend( "<span class='ui-icon ui-icon-minusthick'></span>")
      .end()
    .find( ".portlet-content" );

  $( ".portlet-header .ui-icon" ).click(function() {
    $( this ).toggleClass( "ui-icon-minusthick" ).toggleClass( "ui-icon-plusthick" );
    $( this ).parents( ".portlet:first" ).find( ".portlet-content" ).toggle();
  });

  $( ".column" ).disableSelection();
});
</script>
</head>
<body style="cursor: auto;">
    <div class="container">
        <div class="demo">
            <div class="colbox">
                <div class="colboxtop">
                    <h3>To Do</h3>
                </div>
                <div class="column" colindex="todo">
                    <div class="portlet todo" colindex="todo" id="1">
                    <div class="portlet-header">Task 1</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                    <div class="portlet todo" colindex="todo" id="2">
                    <div class="portlet-header">Task 2</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                </div>
            
                <div class="column" colindex="todo">
                    <div class="portlet todo" colindex="todo" id="3">
                    <div class="portlet-header">Task 3</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
            
            <div class="colbox">
                <div class="colboxtop">
                    <h3>Inprocess</h3>
                </div>
                <div class="column" colindex="inprocess">
                    <div class="portlet inprocess" colindex="inprocess" id="4">
                    <div class="portlet-header">Task 4</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                    
                    <div class="portlet inprocess" colindex="inprocess" id="5">
                    <div class="portlet-header">Task 5</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                </div>
            
                <div class="column" colindex="inprocess"></div>
                <div class="clear"></div>
            </div>
            
            <div class="colbox">
                <div class="colboxtop">
                    <h3>Done</h3>
                </div>
                <div class="column" colindex="done">
                    <div class="portlet done" colindex="done" id="5">
                    <div class="portlet-header">Task 6</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                    
                    <div class="portlet done" colindex="done" id="5">
                    <div class="portlet-header">Task 7</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                </div>
                <div class="column" colindex="done">
                    <div class="portlet done" colindex="done" id="5">
                    <div class="portlet-header">Task 8</div>
                    <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </div><!-- End demo -->
        <div style="clear: both;"></div>
    </div>
</body>
</html>
